package com.observer.demo2.impl;

import java.util.Observable;

public class WeatherData extends Observable {

	// 我们不再需要追踪观察者了，也不需要管理注册与删除（让超类代劳即可）。所以我们把注册、添加、通知的相关代码删除。
	private float temperature;
	private float humidity;
	private float pressure;

	public void measurementsChanged() {
		// 在调用notifuObservers()之前，要先调用setChanged()来指示状态已经改变。
		setChanged();
		notifyObservers();
	}

	public void setMeasurements(float temperature, float humidity,
			float pressure) {
		this.temperature = temperature;
		this.humidity = humidity;
		this.pressure = pressure;
		measurementsChanged();
	}

	public float getTemperature() {
		return temperature;
	}

	public float getHumidity() {
		return humidity;
	}

	public float getPressure() {
		return pressure;
	}

}
